{% extends 'base.html' %}


{% block extra_css %}
<style>
    .product-details-card {
        height: 100%;
    }
    .product-image-container {
        position: relative;
        height: 400px;
        overflow: hidden;
        margin-bottom: 1rem;
        border-radius: 4px;
    }
    .product-image {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }
    .product-info {
        padding: 1.5rem;
    }
    .category-card {
        border: none;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        background: #fff;
    }
    .category-header {
        background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
        color: white;
        padding: 1rem;
        border-radius: 8px 8px 0 0;
    }
    .category-list {
        height: calc(100vh - 200px);
        overflow-y: auto;
        padding: 0.5rem;
    }
    .category-item {
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem;
        margin: 0.25rem 0;
        border-radius: 6px;
        transition: all 0.3s ease;
        cursor: pointer;
        background: #f8f9fa;
    }
    .category-item:hover {
        background: #e9ecef;
        transform: translateX(5px);
    }
    .category-item.active {
        background: #0d6efd;
        color: white;
    }
    .category-item.active:hover {
        background: #0a58ca;
        transform: translateX(5px);
    }
    .category-item {
        display: block;
        padding: 0.75rem 1rem;
        margin: 0.25rem 0;
        border-radius: 6px;
        transition: all 0.3s ease;
        cursor: pointer;
        background: #f8f9fa;
        font-size: 0.9rem;
        text-decoration: none;
        color: #333;
    }
    .sidebar-card {
        height: 100%;
    }
    .category-list {
        height: calc(100vh - 200px);
        overflow-y: auto;
    }
</style>
{% endblock %}

{% block content %}
<div class="container-fluid mt-5 mb-5">
    <div class="row">
        <div class="col-md-8">
            <div class="card product-details-card">
                <div class="card-body">
                    {% if product.image %}
                        <div class="product-image-container">
                            <img src="{{ product.image.url }}" class="product-image" alt="{{ product.title }}">
                        </div>
                    {% endif %}
                    <div class="product-info">
                        <h2 class="card-title mb-3">{{ product.title }}</h2>
                        <div class="mb-3">

                        </div>
                        <div class="mb-4">
                            <p class="card-text">{{ product.description }}</p>
                        </div>
                        <div class="mb-4">
                            <p class="card-text">
                                <small class="text-muted">
                                    <i class="fas fa-user me-1"></i>联系人：{{ product.publisher.nickname }}<br>
                                    <i class="fas fa-user me-1"></i>联系电话：{{ product.publisher.phone }}<br>
                                    <i class="fas fa-clock me-1"></i>发布时间：{{ product.created_at }}<br>
                                    <i class="fas fa-folder me-1"></i>分类：{{ product.category.name }}
                                </small>
                            </p>
                        </div>
                        
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card category-card">
                <div class="category-header">
                    <h5 class="mb-0">商品分类</h5>
                </div>
                <div class="card-body">
                    <div class="category-list">
                        {% for category in categories %}
                        <a href="{% url 'product_list' %}?category={{ category.id }}" class="category-item">
                            {{ category.name }}
                        </a>
                        {% endfor %}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
